package com.peng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peng.entity.Employee;
import com.peng.service.EmployeeService;
import com.peng.mapper.EmployeeMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author dell
* @description 针对表【employee(员工信息)】的数据库操作Service实现
* @createDate 2022-05-21 17:11:39
*/
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee>
    implements EmployeeService{

    @Override
    public Page pageR(Integer page, Integer pageSize, String name) {
        Page<Employee> objectPage = new Page<>(page, pageSize);
        LambdaQueryWrapper<Employee> queryWrapper = new LambdaQueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like(Employee::getUsername,name);
        }
        queryWrapper.orderByDesc(Employee::getUpdateTime);
        Page<Employee> employeePage = baseMapper.selectPage(objectPage, queryWrapper);
        return employeePage;
    }
}




